﻿using Ewelve_Four_HD.BLL;
using Ewelve_Four_HD.DAL;
using Ewelve_Four_HD.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Ewelve_Four_HD.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TypeController : ControllerBase
    {
        private readonly TypeBll typeBll;

        public TypeController(TypeBll _typeBll)
        {
            typeBll = _typeBll;
        }
        /// <summary>
        /// 房态添加
        /// </summary>
        /// <param name="S"></param>
        /// <returns></returns>
        [HttpPost]
        public int TypeAdd(RoomType S)
        {
            try
            {
                return typeBll.TypeAdd(S);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 房态查询分页
        /// </summary>
        /// <param name="TypeName"></param>
        /// <param name="RoomStage"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageSum"></param>
        /// <param name="PageCount"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult TypeShowAll(string? TypeName, int? RoomStage, int PageIndex, int PageSize)
        {
            int PageSum = 0;
            int PageCount = 0;
            var H= typeBll.TypeShowAll(TypeName, RoomStage, PageIndex, PageSize, out PageSum, out PageCount);
            return Ok(new { PageSum = PageSum, PageCount = PageCount,list=H }) ;
        }
    }
}
